public class Solution4 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] hash1= new int[26];
        int[] hash2 = new int[26];
        char[] arr1 = ransomNote.toCharArray();
        char[] arr2 = magazine.toCharArray();
        for(char ch : arr1){
            hash1[ch - 'a']++;
        }
        for(char ch : arr2){
            hash2[ch - 'a']++;
        }
        for(int i = 0; i < 26; i++){
            if(hash1[i] != 0 && hash1[i] > hash2[i]){
                return false;
            }
        }
        return true;
    }
}
